package cm.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "XxlJobInfoDTO", description = "")
public class XxlJobInfoDTO implements Serializable, Comparable<XxlJobInfoDTO> {
    private static final long serialVersionUID = 662714837153297176L;

    @ApiModelProperty(value = "${column.comment}")
    private Integer id;
    
    @ApiModelProperty(value = "执行器主键ID")
    private Integer jobGroup;
    
    @ApiModelProperty(value = "${column.comment}")
    private String jobDesc;
    
    @ApiModelProperty(value = "${column.comment}")
    private LocalDateTime addTime;
    
    @ApiModelProperty(value = "${column.comment}")
    private LocalDateTime updateTime;
    
    @ApiModelProperty(value = "作者")
    private String author;
    
    @ApiModelProperty(value = "报警邮件")
    private String alarmEmail;
    
    @ApiModelProperty(value = "调度类型")
    private String scheduleType;
    
    @ApiModelProperty(value = "调度配置，值含义取决于调度类型")
    private String scheduleConf;
    
    @ApiModelProperty(value = "调度过期策略")
    private String misfireStrategy;
    
    @ApiModelProperty(value = "执行器路由策略")
    private String executorRouteStrategy;
    
    @ApiModelProperty(value = "执行器任务handler")
    private String executorHandler;
    
    @ApiModelProperty(value = "执行器任务参数")
    private String executorParam;
    
    @ApiModelProperty(value = "阻塞处理策略")
    private String executorBlockStrategy;
    
    @ApiModelProperty(value = "任务执行超时时间，单位秒")
    private Integer executorTimeout;
    
    @ApiModelProperty(value = "失败重试次数")
    private Integer executorFailRetryCount;
    
    @ApiModelProperty(value = "GLUE类型")
    private String glueType;
    
    @ApiModelProperty(value = "GLUE源代码")
    private String glueSource;
    
    @ApiModelProperty(value = "GLUE备注")
    private String glueRemark;
    
    @ApiModelProperty(value = "GLUE更新时间")
    private LocalDateTime glueUpdatetime;
    
    @ApiModelProperty(value = "子任务ID，多个逗号分隔")
    private String childJobid;
    
    @ApiModelProperty(value = "调度状态：0-停止，1-运行")
    private Integer triggerStatus;
    
    @ApiModelProperty(value = "上次调度时间")
    private Long triggerLastTime;
    
    @ApiModelProperty(value = "下次调度时间")
    private Long triggerNextTime;

    @ApiModelProperty(value = "执行时间")
    private String executeTime;

    @ApiModelProperty(value = "执行时间")
    private String jobClassName;

    @ApiModelProperty(value = "对应服务名称")
    private String serviceName;

    /**
     * 完整构造函数
     */
    public XxlJobInfoDTO(String executorHandler, String jobClassName, String serviceName) {
        this.executorHandler = executorHandler;
        this.jobClassName = jobClassName;
        this.serviceName = serviceName;
    }

    @Override
    public int compareTo(@NotNull XxlJobInfoDTO o) {
        return this.executeTime.compareTo(o.executeTime);
    }
}

